﻿
@{
    ViewData["Title"] = "写文章";
    Layout = "~/Views/Shared/_Back.cshtml";
}
<script type="text/javascript" src="https://cdn.jsdelivr.net/npm/jquery@3.6.0/dist/jquery.min.js"></script>
<script src="~/tinymce/tinymce.min.js"></script>
<script src="~/tinymce/langs/zh-Hans.js"></script>

<script type="text/javascript">

    $(function () {

        tinymce.init({
            selector: '#txtContent',
            language: "zh-Hans",
            plugins: "table image code",
            toolbar: 'bold italic underline alignleft aligncenter alignright alignjustify fontselect fontsizeselect table image code ',
            images_upload_url: '/File/UploadPic',
            images_upload_base_path: '',
        });

    });  //end page ready

</script>
<form action="/Back/Saveinfo" method="post" enctype="multipart/form-data">
    <div class="layui-card">
        <div class="layui-card-body">
            <div class="layui-row layui-col-space10">
                <div class="layui-col-md4">
                    <h3>文章标题</h3>
                    <input type="text" name="txtTitle" required lay-verify="required" placeholder="请输入标题"
                           autocomplete="off" class="layui-input" id="txtTitle">
                </div>
                <div class="layui-col-md4">
                    <h3>文章简介</h3>
                    <input type="text" class="layui-input" id="txtASynopsis" name="txtASynopsis" placeholder="文章简介">
                </div>
                <div class="layui-col-md2">
                    <h3>发布日期</h3>
                    <input type="text" class="layui-input" id="txtTime" name="txtTime" placeholder="发布日期">
                </div>
                <div class="layui-col-md2">
                    <h3>文章类别</h3>
                    <select class="layui-select" style="width: 100%" id="TypeID" name="TypeID">
                        @foreach (var item in ViewBag.categories)
                        {
                            <option value="@item.CategoryId">@item.Cname</option>
                        }
                    </select>
                </div>
            </div>
        </div>
        <div class="layui-card-body ">
            <h3>文章内容编写</h3>
            <textarea id="txtContent" name="txtContent"></textarea>
            <hr class="layui-border-cyan">
            <input type="submit" id="btnSAVE" name="btnSAVE" value="保存" class="layui-btn layui-btn-radius" />
            <a href="/Back/ArticleList" id="btnCancel" name="btnCancel" class="layui-btn-radius layui-btn layui-btn-normal">取消</a>
            @if (TempData["error"] != null || TempData["success"] != null)
            {
                <p style="color:red">@TempData["error"]@TempData["success"]</p>
            }
        </div>
    </div>
</form>
@section Scripts{ 
    <script>
        layui.use('laydate', function () {
            var laydate = layui.laydate;

            //执行一个laydate实例
            laydate.render({
                elem: '#txtTime' //指定元素
            });
        });
    </script>
}
